package com.iflytek.utils.enums;

public enum ResultEnum {
    // 登录
    CODEERROR(1003, "验证码有误"), ACCOUNTERROR(1004, "账号或密码有误"), NOTOKEN(1005, "token信息为空"), TOKENERROR(1006, "token信息有误"),
    //通用
    SUCCESS(1, "操作成功"), FAILURE(0, "操作失败")
    ,UNDEFINE(-1, "未定义异常信息"),
    //教室信息
    CLASSNO_FAILURE(11,"教编号称已经存在"), CLASSNAME_FAILURE(12,"教室名称已经存在"),
    //管理员
    ADMIN_ACCOUNT_FAILURE(20,"管理员账号已经存在"),ADMIN_PHONE_FAILURE(21,"管理员手机已经存在"),ADMIN_EMAIL_FAILURE(22,"管理员邮箱已经存在")
    ;

    private int code;
    private String msg;

    ResultEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static String msg(int code) {
        for (ResultEnum m : ResultEnum.values()) {
            if (m.getCode() == code) {
                return m.getMsg();
            }
        }
        return UNDEFINE.getMsg();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
